package com.hutao.chargingpile.pitfall.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hutao.chargingpile.pitfall.mapper.CpHiddenManageMapper;
import com.hutao.chargingpile.pitfall.pojo.dto.CpHiddenPageDto;
import com.hutao.chargingpile.pitfall.pojo.entity.CpHidden;
import com.hutao.chargingpile.pitfall.service.CpHiddenManageService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * @作者:卢光云
 * @时间:2023/3/29 11:21
 */
@Service
public class CpHiddenManageServiceImpl extends ServiceImpl<CpHiddenManageMapper, CpHidden> implements CpHiddenManageService {

    @Resource
    private CpHiddenManageMapper cpHiddenManageMapper;

    @Override
    public Page<CpHidden> pageList(CpHiddenPageDto cpHiddenPageDto) {
        Page<CpHidden> page = new Page<>(cpHiddenPageDto.getPageNum(),cpHiddenPageDto.getPageSize());
        Page<CpHidden> selectPage = baseMapper.selectPageList(page,cpHiddenPageDto.getCpHidden());
        return selectPage;
    }

    @Override
    public void updateHidden(CpHidden cpHidden) {
        Long id = cpHidden.getId();
        if (id == 0){
            baseMapper.insert(cpHidden);
        }else {
            cpHiddenManageMapper.updateHidden(cpHidden);
        }
    }
}
